﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace System.Web.Mvc
{
    internal class SuperFileResult : FileResult
    {
        public SuperFileResult(string s):base(s)
        { }

        private int start = 0;
        private int end = 0;
        private void PrsetRange(string range)
        {
            if (string.IsNullOrWhiteSpace(range))
            {
                return;
            }
        }

        public string FileName { get; private set; }
        public Stream FileStream { get; private set; }

        public override void ExecuteResult(ControllerContext context)
        {
            PrsetRange(context.HttpContext.Request.Headers["range"]);
            context.HttpContext.Response.AppendHeader("content-range", string.Format("byte {0}-{1}", start, end == 0 ? "" : end.ToString()));
            base.ExecuteResult(context);
        }

        protected override void WriteFile(HttpResponseBase response)
        {
            if (string.IsNullOrWhiteSpace(FileName))
            {
                this.FileStream = File.OpenRead(FileName);
            }

            using (this.FileStream)
            {
                
            }
        }


        
    }
}
